package com.atguigu.b_test;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
/*
    File --> Java
 */
public class Test4 {
    public static void main(String[] args) throws IOException {
        //读取文件中的学生信息,并存入到学生对象中
        BufferedReader br = new BufferedReader(new FileReader("T_Day23\\test\\StudentInfo.txt"));

        //再把学生对象存到集合中,并遍历
        ArrayList<Student> list = new ArrayList<>();

        String line;
        while((line = br.readLine()) != null){
            //guigu001,刘德华,18,男
            String[] split = line.split(",");
            Student student = new Student(split[0], split[1], Integer.parseInt(split[2]), split[3]);
            //添加到集合中
            list.add(student);
        }

        br.close();

        //遍历集合
        for (Student student : list) {
            System.out.println("student = " + student);
        }
    }
}
